<template>
    <div class="baseInfo">
        <el-form label-width="100px">
            <div class="flexDiv">
                <el-form-item label="病例编号" prop="pathologyId">
                    <el-input v-model="baseInfo.pathologyId" placeholder="病例编号" class="idNumInput">

                    </el-input>
                </el-form-item>
                <el-form-item label-width="0px" class="noLabelItem">
                    <el-button type="primary" :size="device === 'mobile' ? 'mini' : ''">获取资料</el-button>

                </el-form-item>
            </div>
            <div class="flexDiv">
                <el-form-item label="性别" prop="sex">
                    <el-select v-model="baseInfo.sex" placeholder="选择性别" clearable class="idNumInput">
                        <el-option v-for="(data, index) in SexKindList" :key="index" :label="data.name" :value="data.id">
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="年龄" prop="age">
                    <el-input v-model="baseInfo.age" placeholder="输入年龄" class="idNumInput">
                        <el-select v-model="baseInfo.ageUnit" placeholder="" slot="append" size="mini">
                            <el-option v-for="(data, index) in ageUnitKindList" :key="index" :label="data.name"
                                :value="data.id">
                            </el-option>
                        </el-select>
                    </el-input>
                </el-form-item>


                <el-form-item label="标本类别" prop="specimenType">
                    <el-select v-model="baseInfo.specimenType" placeholder="选择标本类别" clearable class="idNumInput">
                        <el-option v-for="(data, index) in specimenCategoryList" :key="index" :label="data.name"
                            :value="data.id">
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="是否冰冻" prop="freezeType">
                    <el-select v-model="baseInfo.freezeType" placeholder="选择是否冰冻" clearable class="idNumInput">
                        <el-option v-for="(data, index) in freezeTypeList" :key="index" :label="data.name" :value="data.id">
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="取材脏器" prop="sampleOrganId">
                    <el-select v-model="baseInfo.sampleOrganId" placeholder="选择取材脏器" clearable class="idNumInput">
                        <el-option v-for="(data, index) in organList" :key="index" :label="data.name" :value="data.id">
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="取材部位" prop="sampleBody">
                    <el-input v-model="baseInfo.sampleBody" placeholder="请输入取材部位" class="idNumInput">

                    </el-input>
                </el-form-item>
                <el-form-item label="病史摘要" prop="pathologySummary">
                    <el-input type="textarea" :rows="3" placeholder="请输入病史摘要" class="idNumtext0"
                        v-model="baseInfo.pathologySummary">
                    </el-input>

                </el-form-item>
                <el-form-item label="巨检描述" prop="pathologyObserved">
                    <el-input type="textarea" :rows="3" placeholder="请输入巨检描述" class="idNumtext0"
                        v-model="baseInfo.pathologyObserved">
                    </el-input>

                </el-form-item>
                <el-form-item label="镜下所见" prop="pathologyClinicalDiagnosis">
                    <el-input type="textarea" :rows="3" placeholder="请输入镜下所见" class="idNumtext0"
                        v-model="baseInfo.pathologyClinicalDiagnosis">
                    </el-input>

                </el-form-item>
            </div>
            <div class="flexDiv">
                <el-form-item label="" prop="sex" label-width="0px" class="noLabelItem" style="margin-bottom:0px!important">
                    <div class="flexDiv">
                        免疫组化和分子病理
                        <el-button type="primary" size="mini" style="margin-left:8px;">上传分子病理结果</el-button>
                    </div>


                </el-form-item>

            </div>
            <el-form-item label="" prop="pathologyImmunology">
                <el-input type="textarea" :rows="3" placeholder="请输入免疫组化和分子病理" class="idNumtext0"
                    v-model="baseInfo.pathologyImmunology">
                </el-input>

            </el-form-item>

            <el-form-item label="病理诊断" prop="pathologyDiagnosis">
                <el-input type="textarea" :rows="3" placeholder="请输入病理诊断" class="idNumtext0"
                    v-model="baseInfo.pathologyDiagnosis">
                </el-input>

            </el-form-item>

            <el-form-item>
                <el-button @click="closeEvent">关 闭</el-button>
                <el-button type="primary" @click="submitForm()">保 存</el-button>

            </el-form-item>
        </el-form>
    </div>
</template>
    
<script>



//自定义校验规则
var checkIdCard = (rule, value, cb) => {
    const regIdCard =
        /^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;
    if (regIdCard.test(value)) {
        return cb();
    }
    cb(new Error("您输入的身份证号码不是有效格式"));
};
var checkPatientPhone = (rule, value, cb) => {
    const regPatientPhone = /^1[3|4|5|6|7|8|9][0-9]\d{8}$/;
    if (regPatientPhone.test(value)) {
        return cb();
    }
    cb(new Error("您输入的手机号码不是有效格式"));
};
export default {
    name: "casesInfo",
    dicts: [

    ],
    props: {
        digitalSlicingData: {
            type: Object,
            default: {},
        },
        pathologyId: { //病例id
            type: [String, Number],
            default: '',
        },
        diagnosisId: { //诊断id
            type: [String, Number],
            default: '',
        },
    },
    components: {

    },
    data() {
        return {
            dictRequestMap: [
                {
                    code: 'patientCategory',
                    arrayKey: 'patientCategoryList',
                },
                {
                    code: 'SexKind',
                    arrayKey: 'SexKindList',
                },
                {
                    code: 'ageUnitKind',
                    arrayKey: 'ageUnitKindList',
                },
                {
                    code: 'specimenCategory',
                    arrayKey: 'specimenCategoryList',
                },
                {
                    code: 'freezeType',
                    arrayKey: 'freezeTypeList',
                },
                {
                    code: 'PC-menopause',
                    arrayKey: 'isMenopauseTypeList',
                },
                {
                    code: 'MarryKind',
                    arrayKey: 'marryTypeList',
                },
                {
                    code: 'PC-Nation',
                    arrayKey: 'nationalTypeList',
                },
                {
                    code: 'sliceCategory',
                    arrayKey: 'sliceCategoryList',
                },
                {
                    code: 'sliceUses',
                    arrayKey: 'sliceUseList',
                },
            ],
            // 顾客信息
            baseInfo: {
                num: undefined,
                id: undefined,
                name: undefined,
                teacher: undefined,
                student: undefined,
                release: 0,
                verify: 0,
                remark: undefined,
                ageUnit: undefined,
                age: undefined
            },
            patientCategoryList: [],
            SexKindList: [],
            ageUnitKindList: [],
            specimenCategoryList: [],
            freezeTypeList: [],
            isMenopauseTypeList: [],
            marryTypeList: [],
            nationalTypeList: [],
            sliceCategoryList: [],
            sliceUseList: [],
            organList: [],

            sexArray: [
                {
                    value: '0',
                    label: '女'
                }, {
                    value: '1',
                    label: '男'
                }
            ],


        };
    },
    computed: {
        device() {
            return this.$store.state.device
        }
    },
    async mounted() {
        //console.log(this.digitalSlicingData)
        this.baseInfo = this.digitalSlicingData
        await this.dictionariesRequest(this.dictionaryMap);
        await this.organsRequest()
    },
    methods: {
        organsRequest() {
            this.$axios({
                // 详见 axios 请求配置项
                method: 'GET',
                url: '/organs',
                params: {
                    size: 10000,
                },
            }).then((res) => {
                if (res && res.data.code === 200) {
                    res.data.data.forEach((t) => {
                        this.organList.push({
                            id: t.id,
                            name: t.name,
                        });
                    });
                }
            });
        },
        dictionariesRequest() {
            this.dictRequestMap.forEach((map) => {
                this.$axios({
                    method: 'GET',
                    url: '/dicts/list',
                    params: {
                        code: map.code,
                        page: 0,
                        size: 99,
                    },
                }).then((res) => {
                    if (res && res.data.code === 200) {
                        this[map.arrayKey] = _.clone(res.data.data);
                    }
                });
            });
        },
        submitForm() {
            this.$emit('submitForm')
        },
        closeEvent() {
            this.$emit('close')
        },
    }
};
</script>
    
<style scoped lang="scss"></style>
    
    